package com.gcx.springbeetlsql.config;

import com.alibaba.druid.pool.DruidDataSource;
import org.beetl.sql.core.SQLManager;
import org.beetl.sql.starter.SQLManagerCustomize;
import org.springframework.boot.SpringBootConfiguration;
import org.springframework.context.annotation.Bean;

import javax.sql.DataSource;
import javax.xml.crypto.Data;

/**
 * @Title:
 * @Description:
 * @date 2022/5/7 11:32
 */
@SpringBootConfiguration
public class SQLManagerConfiguration{
    /**
     *  SQLManagerCustomize对象会自动定制SQLManager对象
     * @return SQLManagerCustomize：SQLManager定制化对象
     */
    @Bean
    public SQLManagerCustomize mySQLManagerCustomize(){
        return new SQLManagerCustomize(){
            @Override
            public void customize(String sqlManagerName, // yml中定义的mySqlManager
                                  SQLManager manager){
                //初始化sql，这里也可以对sqlManager进行修改
                // 可以执行如下：通过sql脚本创建数据库
                // DBInitHelper.executeSqlScript(manager,"db/schema.sql");
            }
        };
    }
}
